/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ie.deloitte.cvapp.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author damorales
 */
@Entity
@Table(name = "employee", catalog = "javabootcamp", schema = "")
@NamedQueries({
    @NamedQuery(name = "Employee.findAll", query = "SELECT e FROM Employee e"),
    @NamedQuery(name = "Employee.findByIdEmployee", query = "SELECT e FROM Employee e WHERE e.idEmployee = :idEmployee"),
    @NamedQuery(name = "Employee.findByNameSurnameRoleEmailSkills", query = "SELECT e FROM Employee e WHERE (soundex(e.name) = soundex(:name) or e.name like :name2)  and (soundex(e.surname) = soundex(:surname) or e.surname like :surname2) and (soundex(e.email) like soundex(:email))"), // and (e.skills.name like :skills))"), //and (e.roleproposed like :roleproposed)
    @NamedQuery(name = "Employee.findBySurname", query = "SELECT e FROM Employee e WHERE e.surname = :surname"),
    @NamedQuery(name = "Employee.findByProfile", query = "SELECT e FROM Employee e WHERE e.profile = :profile"),
    @NamedQuery(name = "Employee.findByRoleproposed", query = "SELECT e FROM Employee e WHERE e.roleproposed = :roleproposed"),
    @NamedQuery(name = "Employee.findByPhoto", query = "SELECT e FROM Employee e WHERE e.photo = :photo"),
    @NamedQuery(name = "Employee.findByCreationdate", query = "SELECT e FROM Employee e WHERE e.creationdate = :creationdate"),
    @NamedQuery(name = "Employee.findByEmail", query = "SELECT e FROM Employee e WHERE e.email = :email"),
    @NamedQuery(name = "Employee.findByPrimarytelephone", query = "SELECT e FROM Employee e WHERE e.primarytelephone = :primarytelephone"),
    @NamedQuery(name = "Employee.findBySecondarytelepohne", query = "SELECT e FROM Employee e WHERE e.secondarytelepohne = :secondarytelepohne")})
	//@NamedQuery(name = "Employee.findByNameSurname", query = "SELECT e FROM Employee e WHERE lower(e.name) like lower(%:name%)")}) //or e.surname = %:surname%
public class Employee implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    //@Basic(optional = false)
    //@NotNull
    @Column(name = "idEmployee", nullable = false)
    private Integer idEmployee;
    @Size(max = 45)
    @Column(name = "name", length = 45)
    private String name;
    @Size(max = 45)
    @Column(name = "surname", length = 45)
    private String surname;
    @Size(max = 4000)
    @Column(name = "profile", length = 4000)
    private String profile;
    @Size(max = 45)
    @Column(name = "roleproposed", length = 45)
    private String roleproposed;
    @Size(max = 100)
    @Column(name = "photo", length = 100)
    private String photo;
    @Column(name = "creationdate")
    @Temporal(TemporalType.DATE)
    private Date creationdate;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Size(max = 255)
    @Column(name = "email", length = 255)
    private String email;
    @Size(max = 100)
    @Column(name = "primarytelephone", length = 100)
    private String primarytelephone;
    @Size(max = 100)
    @Column(name = "secondarytelepohne", length = 100)
    private String secondarytelepohne;
    
	
   @OneToMany(mappedBy="employee", fetch=FetchType.EAGER)
    private Set<EmployeeHasSkill> skills = new HashSet<EmployeeHasSkill>();
	
	
 //   @Size(max = 45)
 //   @Column(name = "skills", length = 100)
 //   private String skills;........................Maxine

    public Employee() {
    }

    public Employee(Integer idEmployee) {
        this.idEmployee = idEmployee;
    }

    public Integer getIdEmployee() {
        return idEmployee;
    }

    public void setIdEmployee(Integer idEmployee) {
        this.idEmployee = idEmployee;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSurname() {
        return surname;
    }

    public void setSurname(String surname) {
        this.surname = surname;
    }

    public String getProfile() {
        return profile;
    }

    public void setProfile(String profile) {
        this.profile = profile;
    }

    public String getRoleproposed() {
        return roleproposed;
    }

    public void setRoleproposed(String roleproposed) {
        this.roleproposed = roleproposed;
    }
    
 /*   public String getSkillsMatrix() {
        return skills;
    }

    public void setSkillsMatix(String skills) {
        this.skills = skills;
    }
.............Maxine*/
    public String getPhoto() {
        return photo;
    }

    public void setPhoto(String photo) {
        this.photo = photo;
    }

    public Date getCreationdate() {
        return creationdate;
    }

    public void setCreationdate(Date creationdate) {
        this.creationdate = creationdate;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPrimarytelephone() {
        return primarytelephone;
    }

    public void setPrimarytelephone(String primarytelephone) {
        this.primarytelephone = primarytelephone;
    }

    public String getSecondarytelepohne() {
        return secondarytelepohne;
    }

    public void setSecondarytelepohne(String secondarytelepohne) {
        this.secondarytelepohne = secondarytelepohne;
    }

    
    public Set<EmployeeHasSkill> getSkills() {
		return skills;
	}

	public void setSkills(Set<EmployeeHasSkill> skills) {
		this.skills = skills;
	}

	@Override
    public int hashCode() {
        int hash = 0;
        hash += (idEmployee != null ? idEmployee.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Employee)) {
            return false;
        }
        Employee other = (Employee) object;
        if ((this.idEmployee == null && other.idEmployee != null) || (this.idEmployee != null && !this.idEmployee.equals(other.idEmployee))) {
            return false;
        }
        return true;
    }

	@Override
	public String toString() {
		return "Employee [idEmployee=" + idEmployee + ", name=" + name
				+ ", surname=" + surname + ", profile=" + profile
				+ ", roleproposed=" + roleproposed + ", photo=" + photo
				+ ", creationdate=" + creationdate + ", email=" + email
				+ ", primarytelephone=" + primarytelephone
				+ ", secondarytelepohne=" + secondarytelepohne + "]";
	}


    
}
